package nc.bs.nft.pub.func;

import java.util.Stack;

import nc.vo.pub.lang.UFDate;

import org.nfunk.jep.ParseException;
import org.nfunk.jep.function.PostfixMathCommand;


public class DateSubstringFunc extends PostfixMathCommand {

	/**
	 * 
	 */
	public DateSubstringFunc() {
		numberOfParameters = 2;
	}
	
	
	/* (non-Javadoc)
	 * @see org.nfunk.jep.function.PostfixMathCommandI#run(java.util.Stack)
	 */
	public void run(Stack st) throws ParseException {
		checkStack(st);
		
		Object ed = st.pop();
		String ds= ed.toString();
		Object ea = st.pop();
		String es= ed.toString();
		if(es.equals("1")&&es.length()>0){
			st.push(ds==null?"":Integer.valueOf(ds.substring(0,4)));
		}else{
			st.push(ds==null?"":ds.substring(4));
			}
	}
}
